﻿__CreateJSPath = function (js) {
    var scripts = document.getElementsByTagName("script");
    var path = "";
    for (var i = 0, l = scripts.length; i < l; i++) {
        var src = scripts[i].src;
        if (src.indexOf(js) != -1) {
            var ss = src.split(js);
            path = ss[0];
            break;
        }
    }
    var href = location.href;
    href = href.split("#")[0];
    href = href.split("?")[0];
    var ss = href.split("/");
    ss.length = ss.length - 1;
    href = ss.join("/");
    if (path.indexOf("https:") == -1 && path.indexOf("http:") == -1 && path.indexOf("file:") == -1 && path.indexOf("\/") != 0) {
        path = href + "/" + path;
    }
    return path;
}

function boot_isEmpty(str) {
	str = str + "";
	if (str == null || str == "" || str == 'undefined'
			|| boot_trim(str) == "" || str == "null" || str == undefined)
		return true;
	else
		return false;
}

//去掉空格
function boot_trim(str) {
	if(str==null || str==undefined) {
		return "";
	}
	str = str + "";
	if (str == null || str == "" || str == 'undefined')
		str = "";
	str = str.replace(/\s/g, "");
	str = str.replace("　", "");
	return str;
}

var bootPATH = __CreateJSPath("boot.js");


console.log("----------------" + bootPATH + "-----------------------------");

//debugger
mini_debugger = true;
// http://localhost:8080/js/scripts/
//miniui
document.write('<script src="' + bootPATH + 'fzzl/js/jquery-1.12.4.min.js" type="text/javascript"></script>');
document.write('<script src="' + bootPATH + 'miniui/miniui.js" type="text/javascript" ></script>');
document.write('<link href="' + bootPATH + 'miniui/themes/default/miniui.css" rel="stylesheet" type="text/css" />');
document.write('<link href="' + bootPATH + 'miniui/themes/icons.css" rel="stylesheet" type="text/css" />');

//skin
var skin = getCookie("miniuiSkin");
if(boot_isEmpty(skin)) skin="metro-green";
if (skin) {
    document.write('<link href="' + bootPATH + 'miniui/themes/' + skin + '/skin.css" rel="stylesheet" type="text/css" />');
}

//mode
var mode = getCookie("miniuiMode");
if(boot_isEmpty(mode)) mode="default";
if (mode && mode != 'default') {
    document.write('<link href="' + bootPATH + 'miniui/themes/default/' + mode + '-mode.css" rel="stylesheet" type="text/css" />');
}

////////////////////////////////////////////////////////////////////////////////////////
function getCookie(sName) {
    var aCookie = document.cookie.split("; ");
    var lastMatch = null;
    for (var i = 0; i < aCookie.length; i++) {
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0]) {
            lastMatch = aCrumb;
        }
    }
    if (lastMatch) {
        var v = lastMatch[1];
        if (v === undefined) return v;
        return unescape(v);
    }
    return null;
}